home *** CD-ROM | disk | FTP | other *** search
/ Champak 50 / Volume 50 - JOGO DISK .iso / Games / mallcrawl.swf / scripts / __Packages / ElevatorDoor.as < prev    next >
Encoding:
Text File  |  2007-09-28  |  2.4 KB  |  87 lines

  1. class ElevatorDoor extends MovieClip
  2. {
  3.    var onEnterFrame;
  4.    var HitSquare;
  5.    var direction;
  6.    var step_out_id;
  7.    var step_in_id;
  8.    var FADE_SPEED = 110;
  9.    var out = false;
  10.    function ElevatorDoor()
  11.    {
  12.       super();
  13.       this.onEnterFrame = this.defaultEnterFrame;
  14.       this.gotoAndStop("closed");
  15.    }
  16.    function defaultEnterFrame()
  17.    {
  18.       if(this.HitSquare.hitTest(_global.Rescuer))
  19.       {
  20.          if(Key.isDown(38))
  21.          {
  22.             if(this._name != "Door3")
  23.             {
  24.                this.direction = 1;
  25.                _global.Rescuer.is_available = false;
  26.                _global.Rescuer.invincible = true;
  27.                _global.Rescuer.Char.gotoAndStop("still");
  28.                this.gotoAndPlay("open");
  29.                this._parent.disable();
  30.             }
  31.          }
  32.          if(Key.isDown(40))
  33.          {
  34.             if(this._name != "Door1")
  35.             {
  36.                this.direction = -1;
  37.                _global.Rescuer.is_available = false;
  38.                _global.Rescuer.invincible = true;
  39.                _global.Rescuer.Char.gotoAndStop("still");
  40.                this.gotoAndPlay("open");
  41.                this._parent.disable();
  42.             }
  43.          }
  44.       }
  45.    }
  46.    function stepOut()
  47.    {
  48.       _global.Rescuer.glevel += this._parent.in_elev.direction;
  49.       _global.Rescuer.resetGround();
  50.       _global.Rescuer.fillMovement();
  51.       this.step_out_id = setInterval(this,"steppingOut",10);
  52.    }
  53.    function steppingOut()
  54.    {
  55.       _global.Rescuer.fadeAlpha(_global.Rescuer._alpha + this.FADE_SPEED);
  56.       if(_global.Rescuer._alpha >= 100)
  57.       {
  58.          clearInterval(this.step_out_id);
  59.          _global.Rescuer.is_available = true;
  60.          _global.Rescuer._alpha = 100;
  61.          if(!_global.Rescuer.currentPowerItem)
  62.          {
  63.             _global.Rescuer.invincible = false;
  64.          }
  65.          this.out = false;
  66.          this._parent.enable();
  67.          this.play();
  68.       }
  69.    }
  70.    function stepIn()
  71.    {
  72.       this._parent.in_elev = this;
  73.       _global.Rescuer.accel = 0;
  74.       this.step_in_id = setInterval(this,"steppingIn",10);
  75.    }
  76.    function steppingIn()
  77.    {
  78.       _global.Rescuer.fadeAlpha(_global.Rescuer._alpha - this.FADE_SPEED);
  79.       if(_global.Rescuer._alpha <= 0)
  80.       {
  81.          clearInterval(this.step_in_id);
  82.          _global.Rescuer._alpha = 0;
  83.          this.play();
  84.       }
  85.    }
  86. }
  87.